home *** CD-ROM | disk | FTP | other *** search
/ SGI Hot Mix 17 / Hot Mix 17.iso / HM17_SGI / research / examples / doc / sigprc10 < prev    next >
Text File  |  1997-07-08  |  1KB  |  36 lines

  1. ; This batch file creates a plot a bandstop filter which suppresses
  2. ; frequencies between 7 cycles per second and 15 cycles per second for
  3. ; data sampled every 0.02 seconds. It is used in Chapter 13,
  4. ; "Signal Processing", of _Using IDL_.
  5.  
  6. delt = 0.02 ; sampling period in seconds
  7.  
  8. f_low = 15. ; frequencies above f_low will be passed
  9.  
  10. f_high = 7. ; frequencies below f_high will be passed
  11.  
  12. a_ripple = 50. ; ripple amplitude will be less than -50 dB
  13.  
  14. nterms = 40 ; the order of the filter
  15.  
  16. ; Compute the impulse response = the filter coefficients
  17.  
  18. bs_ir_k = DIGITAL_FILTER(f_low*2*delt, f_high*2*delt, a_ripple, nterms)
  19.  
  20. ; The frequency response of the filter is the FFT of its impulse response: 
  21.  
  22. nfilt = N_ELEMENTS(bs_ir_k) ; nfilt = number of points in impulse response
  23.  
  24. bs_fr_k = FFT(bs_ir_k) * nfilt ; scale frequency response by number of pts
  25.  
  26. ; log plot of magnitude in dB
  27.  
  28. f_filt = FINDGEN(nfilt/2+1) / (nfilt*delt)
  29.  
  30. mag = ABS(bs_fr_k(0:nfilt/2)) ; magnitude of bandstop filter transfer f'n
  31.  
  32. PLOT, f_filt, 20*ALOG10(mag), YTITLE='Magnitude in dB', $
  33.     XTITLE='Frequency in cycles / second', /XLOG, $
  34.     XRANGE=[1.0,1.0/(2.0*delt)], XSTYLE=1, $
  35.     TITLE='Frequency Response for Bandstop!CFIR Filter (Kaiser)'
  36.